package prolog.fluents

import java.util.ArrayList;
import java.util.{Iterator => e};
import prolog.terms.Prog;
import prolog.terms.Source;
import prolog.terms.Term;
import scala.collection.JavaConversions._
import scala.collection.mutable._

/**
  Builds Prolog Iterators from Java
  Sequences and Iterator type classes
*/
 class JavaSource1 extends prolog.terms.Source,prolog.terms.Prog  {
  private val e:Iterator;
//functions  	
  def this(p:Prog) = this(super.p, e=null)
  def this(iterator:Term,p:Prog) = this(super.p, e=iterator)
  def this(V:ArrayList,p:Prog)= this(super.p , e=V.iterator())
  
  //get element
  override def getElement():Term = {
    if(null==e||!e.hasNext())
       null;
    else
       (Term)e.next();
  }
  
  override def stop():Unit {
    e=null;
  }
}